#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

static int perfect_square(int num) {
    int r = sqrt(num) + .5;
    return r * r == num ? r : 0;
}

int main() {
    vector<int> v (1000, 0);
    for (int i = 1; i < 500; ++i) {
        for (int j = i + 1; j < 500; ++j) {
            int k = perfect_square(i*i + j*j);
            int p = i + j + k;
            if (k && p <= 1000)
                ++v[p];
        }
    }
    cout << distance(v.begin(), max_element(v.begin(), v.end())) << endl; // 840
}